package com.qf.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author 刘亚康
 * @Date 2020/3/27
 * @Version 1.0'
 * @Description
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResultMsg<T> {
    private static final String STATUS_SUC="ok";

    private static final String SUC_MSG="操作成功";

    private static final String STATUS_FAIL="error";

    private static final String FAIL_MSG="操作失败";

    private static final String NO_DATA="";

    private static final String NO_URL="";

    private String status;

    private String msg;

    private T data;

    private String url;



    /**
     * 成功的返回消息
     * @return
     */
    public static ResultMsg success(){
        return new ResultMsg(STATUS_SUC,SUC_MSG,NO_DATA,NO_URL);
    }

    /**
     * 成功的返回消息并跳转网址
     * @return
     */
    public static ResultMsg success(String url){
        return new ResultMsg(STATUS_SUC,SUC_MSG,NO_DATA,url);
    }
    /**
     * 成功的自定义返回消息并跳转网址
     * @return
     */
    public static ResultMsg success(String msg,String url){
        return new ResultMsg(STATUS_SUC,msg,NO_DATA,url);
    }
    /**
     * 成功的自定义返回消息并跳转网址
     * @return
     */
    public static ResultMsg successMsg(String msg){
        return new ResultMsg(STATUS_SUC,msg,NO_DATA,NO_URL);
    }

    /**
     * 失败的返回消息
     * @return
     */
    public static ResultMsg fail(){
        return new ResultMsg(STATUS_FAIL,FAIL_MSG,NO_DATA,NO_URL);
    }
    /**
     * 失败的返回消息
     * @return
     */
    public static ResultMsg fail(String msg){
        return new ResultMsg(STATUS_FAIL,msg,NO_DATA,NO_URL);
    }

}
